<template>
  <div class="main-container">
    <div class="main-header">
      <el-breadcrumb separator="/">
        <el-breadcrumb-item>QA管理</el-breadcrumb-item>
      </el-breadcrumb>
    </div>
    <div class="wrap">
      <div class="content">
        <div class="search-container">
          <el-form class="search-form" :model="form" ref="form" label-width="90px" label-position="right" inline>
            <el-row>
              <el-form-item label="问题名称" prop="questionName">
                <el-input v-model="form.questionName"></el-input>
              </el-form-item>
              <el-form-item label="学员姓名" prop="customerName">
                <el-input v-model="form.customerName"></el-input>
              </el-form-item>
              <el-form-item label="学员手机号" prop="customerPhone">
                <el-input v-model="form.customerPhone"></el-input>
              </el-form-item>
              <el-form-item>
                <el-button type="primary" @click="onSearch">查询</el-button>
                <el-button @click="onReset">重置</el-button>
              </el-form-item>
            </el-row>
          </el-form>
        </div>
        <div class="mt-10">
          <el-table :data="data" v-loading="loading">
            <!-- <el-table-column type="selection" width="55" fixed>
            </el-table-column> -->
            <el-table-column prop="questionName" label="问题" min-width="200" show-overflow-tooltip>
            </el-table-column>
            <el-table-column prop="nickName" label="学员姓名" min-width="130" show-overflow-tooltip>
            </el-table-column>
            <el-table-column prop="phoneNumber" label="学员手机号" min-width="150" show-overflow-tooltip>
            </el-table-column>
            <el-table-column prop="createDate" label="提问时间" min-width="160" show-overflow-tooltip>
              <template slot-scope="scope">
                {{$utils.dateFormat(new Date(scope.row.createDate), 'yyyy-MM-dd hh:mm:ss')}}
              </template>
            </el-table-column>
            <!-- <el-table-column label="操作"  width="120" fixed="right">
              <template slot-scope="scope">
                <el-button type="text" @click="doEdit(scope.row.qaid)">回答问题</el-button>
              </template>
            </el-table-column> -->
          </el-table>
        </div>
        <div class="mt-10 t-right" v-if="total > 0">
          <el-pagination
            background
            :current-page="currentPage"
            :total="total"
            :page-sizes="[10, 20, 50]"
            :page-size="pageSize"
            layout="total, sizes, prev, pager, next, jumper"
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
            >
          </el-pagination>
        </div>
      </div>
    </div>
    <!-- <m-answer :data="editData" :visible.sync="editVisible"></m-answer> -->
  </div>
</template>

<script>
// import EditModel from './answer'
  export default {

    data () {
      return {
        currentPage: 1,
        pageSize: 10,
        form: {},
        data: [],
        showTotal: false,
        total: 0,
        loading: false,
        editData: {},
        editVisible: false,
      }
    },
    created() {
      this.loadData()
    },
    activated() {
      this.loadData()
    },
    methods: {
      loadData() {
        this.loading = true
        const params ={
          ...this.form,
          currentPage: this.currentPage,
          pageSize: this.pageSize,
        }
        this.$api.qa.getList(params).then(res => {
          if(res.success){
            this.data = res.data.list
            this.total = res.data.total
            this.loading = false
          }else {
            this.loading = false
          }
        }).catch(err => {
          this.loading = false
        })
      },
      onSearch() {
        this.currentPage = 1
        this.loadData()
      },
      onReset() {
        this.$refs.form.resetFields()
        this.currentPage = 1
        this.loadData()
      },
      // 修改
      // doEdit(data) {
      //   this.editData = data
      //   this.editVisible = true
      // },
      handleSizeChange(val) {
        this.pageSize = val
        this.currentPage = 1
        this.loadData()
      },
      handleCurrentChange(val) {
        this.currentPage = val
        this.loadData()
      }
    }
  }
</script>

<style>

 
</style>
